package emd24.telstudyresources;

import android.os.Bundle;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.SharedPreferences;
import android.view.Menu;
import android.webkit.WebView;

public class SolutionActivity extends Activity {
	
	private WebView solutionText;
	private SharedPreferences prefs;
	@SuppressLint("SetJavaScriptEnabled")
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_solution);
		Bundle b = this.getIntent().getExtras();
		Question q = b.getParcelable("question");
		// Configure the web-view
		this.solutionText = (WebView) this.findViewById(R.id.wv_solution);
		this.solutionText.getSettings().setJavaScriptEnabled(true);
		this.solutionText.getSettings().setBuiltInZoomControls(true);
		prefs = getPreferences(MODE_PRIVATE);
		if (prefs.getString("MathJaxURL","").length() == 0) {
			SharedPreferences.Editor editprefs = prefs.edit();
			editprefs.putString("MathJaxURL", getResources().getString(R.string.mJaxUrl));	
			editprefs.commit();
		}
		this.solutionText.loadUrl(q.getSolutionText());
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.activity_solution, menu);
		return true;
	}

}
